<%
# Copyright (C) 2012 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
%>

<% debugging = config.debugging? %>
<div class="debug_label">
  <%= before_label(:state_of_debug, "Testing state") %>
</div>
<pre>
  <%= config.debug_get("debugging") %>
</pre>

<% if config.debug_get("request_id") %>
  <h3>
    {{#t}}AuthnRequest sent to IdP{{/t}}
  </h3>
  <div class="debug_label">
    <%= before_label(:request_id, "Request ID") %>
  </div>
  <pre><%= config.debug_get("request_id") %></pre>
<% end %>

<% if config.debug_get("to_idp_url") %>
  <div class="debug_label">
    <%= before_label(:to_idp_url, "LoginRequest encoded URL") %>
  </div>
  <pre class="debug_xml">
    <%= config.debug_get("to_idp_url") %>
  </pre>
<% end %>

<% if config.debug_get("to_idp_xml") %>
  <div class="debug_label">
    <%= before_label(:to_idp_xml, "LoginRequest XML sent to IdP") %>
  </div>
  <pre class="debug_xml">
    <%= config.debug_get("to_idp_xml") %>
  </pre>
<% end %>

<% if config.debug_get("idp_in_response_to") %>
  <h3>
    {{#t}}AuthnResponse from IdP{{/t}}
  </h3>
  <div class="debug_label">
    <%= before_label(:idp_in_response_to, "IdP inResponseTo") %>
  </div>
  <pre>
    <%=config.debug_get("idp_in_response_to")%>
  </pre>
<% end %>

<% if config.debug_get("idp_login_destination") %>
  <div class="debug_label">
    <%= before_label(:idp_login_destination,
                     "IdP LoginResponse destination") %>
  </div>
  <pre>
    <%=config.debug_get("idp_login_destination")%>
  </pre>
<% end %>

<% if config.debug_get("fingerprint_from_idp") %>
  <div class="debug_label">
    <%= before_label(:fingerprint_from_idp,
                     "IdP certificate fingerprint") %>
  </div>
  <pre>
    <%=config.debug_get("fingerprint_from_idp")%>
  </pre>
<% end %>

<% if config.debug_get("is_valid_login_response") %>
  <div class="debug_label">
    <%= before_label(:is_valid_login_response,
                     "Canvas thinks response is valid") %>
  </div>
  <pre>
    <%=config.debug_get("is_valid_login_response")%>
  </pre>
<% end %>

<% if config.debug_get("login_response_validation_error") %>
  <div class="debug_label">
    <%= before_label(:login_response_validation_error,
                     "Validation Error") %>
  </div>
  <pre class="debug_xml">
    <%=config.debug_get("login_response_validation_error")%>
  </pre>
<% end %>

<% if config.debug_get("login_to_canvas_success") %>
  <div class="debug_label">
    <%= before_label(:login_to_canvas_success,
                     "User successfully logged into Canvas") %>
  </div>
  <pre>
    <%=config.debug_get("login_to_canvas_success")%>
  </pre>
<% end %>

<% if config.debug_get("canvas_login_fail_message") %>
  <div class="debug_label">
    <%= before_label(:canvas_login_fail_message,
                    "Canvas Login failure message") %>
  </div>
  <pre>
    <%=config.debug_get("canvas_login_fail_message")%>
  </pre>
<% end %>

<% if config.debug_get("logged_in_user_id") %>
  <div class="debug_label">
    <%= before_label(:logged_in_user_id, "Logged in user id") %>
  </div>
  <pre>
    <%=config.debug_get("logged_in_user_id")%>
  </pre>
<% end %>

<% if config.debug_get("idp_response_encoded") %>
  <div class="debug_label">
    <%= before_label(:idp_response_encoded,
                     "IdP LoginResponse encoded") %>
  </div>
  <pre class="debug_xml">
    <%= config.debug_get("idp_response_encoded") %>
  </pre>
 <% end %>

<% if config.debug_get("idp_response_xml_encrypted") %>
  <div class="debug_label">
    <%= before_label(:idp_response_xml_encrypted,
                     "IdP LoginResponse Encrypted") %>
  </div>
  <pre class="debug_xml">
    <%=config.debug_get("idp_response_xml_encrypted")%>
  </pre>
<% end %>

<% if config.debug_get("idp_response_xml_decrypted") %>
  <div class="debug_label">
    <%= before_label(:idp_response_xml_decrypted,
                     "IdP LoginResponse Decrypted") %>
  </div>
  <pre class="debug_xml">
    <%=config.debug_get("idp_response_xml_decrypted")%>
  </pre>
<% end %>

<% if config.debug_get("logout_request_id") %>
  <h3>
    {{#t}}LogoutRequest sent to IdP{{/t}}
  </h3>
  <div class="debug_label">
    <%= before_label(:logout_request_id, "Logout request id") %>
  </div>
  <pre>
    <%=config.debug_get("logout_request_id")%>
  </pre>
<% end %>

<% if config.debug_get("logout_to_idp_url") %>
  <div class="debug_label">
    <%= before_label(:logout_to_idp_url,
                     "LogoutRequest encoded URL") %>
  </div>
  <pre class="debug_xml">
    <%=config.debug_get("logout_to_idp_url")%>
  </pre>
<% end %>

<% if config.debug_get("logout_to_idp_xml") %>
  <div class="debug_label">
    <%= before_label(:logout_to_idp_xml,
                     "LogoutRequest XML sent to IdP") %>
  </div>
  <pre class="debug_xml">
    <%=config.debug_get("logout_to_idp_xml")%>
  </pre>
<% end %>

<% if config.debug_get("idp_logout_response_encoded") %>
  <h3>
    {{#t}}LogoutResponse from IdP{{/t}}
  </h3>

  <% if config.debug_get("idp_logout_in_response_to") %>
    <div class="debug_label">
      <%= before_label(:idp_logout_in_response_to,
                       "IdP logout inResponseTo") %>
    </div>
    <pre>
      <%=config.debug_get("idp_logout_in_response_to")%>
    </pre>
  <% end %>

  <% if config.debug_get("idp_logout_destination") %>
    <div class="debug_label">
      <%= before_label(:idp_logout_destination,
                       "Idp LogoutResponse destination") %>
    </div>
    <pre>
      <%=config.debug_get("idp_logout_destination")%>
    </pre>
  <% end %>

  <div class="debug_label">
    <%= before_label(:idp_logout_response_encoded,
                     "IdP LogoutResponse encoded") %>
  </div>
  <pre class="debug_xml">
    <%=config.debug_get("idp_logout_response_encoded")%>
  </pre>
<% end %>

<% if config.debug_get("idp_logout_response_xml_encrypted") %>
  <div class="debug_label">
    <%= before_label(:idp_logout_response_xml_encrypted,
                     "IdP LogoutResponse XML") %>
  </div>
  <pre class="debug_xml">
    <%=config.debug_get("idp_logout_response_xml_encrypted")  %>
  </pre>
<% end %>
